﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using DevExpress.XtraTabbedMdi;
using DevExpress.LocalizationCHS;

namespace CollegeShop.Repository.Win
{
    public partial class F_Base : DevExpress.XtraEditors.XtraForm
    {
        public F_Base()
        {
            InitializeComponent();
            DevExpress.Accessibility.AccLocalizer.Active = new DevExpressUtilsLocalizationCHS();
        }
        public void SetSkin(DevExpress.LookAndFeel.DefaultLookAndFeel lookAndFeel)
        {
            lookAndFeel = new DevExpress.LookAndFeel.DefaultLookAndFeel();
            lookAndFeel.LookAndFeel.SkinName = Program.skinNameGlobal;
        }

        //1、打开新的窗口
        public void OpenLink(DevExpress.XtraEditors.XtraForm itemForm, XtraTabbedMdiManager xtraTabbedMdiManager1, string itemHeader)
        {
            //遍历已打开的TabPage,若发现已打开过则不再重复打开并设置为Active
            int itemCount = xtraTabbedMdiManager1.Pages.Count;
            foreach (XtraMdiTabPage itemPage in xtraTabbedMdiManager1.Pages)
            {
                if (itemHeader == itemPage.Text)
                {
                    //设置活动Tab Page
                    xtraTabbedMdiManager1.SelectedPage = itemPage;
                    return;
                }
            }
            itemForm.MdiParent = this;
            itemForm.Show();
            if (itemCount != 0)
            {
                //设置为Active
                xtraTabbedMdiManager1.SelectedPage = xtraTabbedMdiManager1.Pages[itemCount];
            }
        }
    }
}
